/**
 * @file tkl_group_ota.h
 * @brief This is tkl_group_ota file
 * @version 1.0
 * @date 2022-09-26
 *
 * @copyright Copyright 2021-2031 Tuya Inc. All Rights Reserved.
 *
 */

#ifndef __TKL_GROUP_OTA_H__
#define __TKL_GROUP_OTA_H__

#include "tuya_cloud_types.h"
#include "tuya_error_code.h"

#ifdef __cplusplus
extern "C" {
#endif

/***********************************************************************
 ********************* constant ( macro and enum ) *********************
 **********************************************************************/


/***********************************************************************
 ********************* struct ******************************************
 **********************************************************************/


/***********************************************************************
 ********************* variable ****************************************
 **********************************************************************/


/***********************************************************************
 ********************* function ****************************************
 **********************************************************************/

/**
 * @brief SOC ota storage area erase
 * 
 * @param addr start address
 * @param size  length
 * @return OPERATE_RET 
 */
OPERATE_RET tkl_group_ota_data_erase(CONST UINT32_T addr, CONST UINT32_T size);
/**
 * @brief firmware write
 * 
 * @param addr operation address
 * @param src 
 * @param size 
 * @param total_size firmware total size
 * @return OPERATE_RET 
 */
OPERATE_RET tkl_group_ota_data_write(UINT32_T addr, CONST UCHAR_T *src, UINT32_T size, UINT32_T total_size);
/**
 * @brief firmware pre validate
 * 
 * @param total_size firmware total sieze
 * @param version destination version
 * @return OPERATE_RET 
 */
OPERATE_RET tkl_group_ota_firmware_pre_validate(UINT32_T total_size,UINT8_T version);
/**
 * @brief firmware step validate
 * 
 * @param total_size firmware total size
 * @param version destination version
 * @return OPERATE_RET,firmware check complete pass when return OPRT_OK,otherwise,trigger next step validate
 */
OPERATE_RET tkl_group_ota_firmware_step_validate(UINT32_T total_size,UINT8_T version);
/**
 * @brief firware check(integrity,validity) pass,then execute upgrade
 * 
 * @param version destination version
 * @return OPERATE_RET 
 */
OPERATE_RET tkl_group_ota_execute(UINT8_T version);
#ifdef __cplusplus
}
#endif

#endif /* __TKL_GROUP_OTA_H__ */

